package com.example.logindb.repository;

import com.example.logindb.dto.UserDTO;
import com.example.logindb.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;



import java.util.List;
import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<User, Integer> {

    void deleteById(int id);

    User findByUsername(String phone);
    Optional<User> findById(int id);

    List<User> findAllByRole(String role);
    List<User> findAllByRoleAndNameStartingWithIgnoreCase(String role,String name);

    boolean existsByUsername(String phone);
    int countByUserrole(String role);

    List<User> findAllByIdIn(List<Integer> blindids);

    User findAllById(int id);

    Page<User> findByRoleAndUsernameContaining(String user, String name, Pageable pageable);

    List<User> findAllByName(String name);
}
